package com.example.sys.wx.handler;

import com.example.sys.wx.config.WechatOpenProperties;
import me.chanjar.weixin.mp.api.WxMpMessageHandler;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

public abstract class AbstractWxMpMessageHandler implements WxMpMessageHandler, ApplicationContextAware {

    private ApplicationContext applicationContext;

    private WechatOpenProperties wechatOpenProperties;

    public WechatOpenProperties getWechatOpenProperties() {
        if (this.wechatOpenProperties == null) {
            this.wechatOpenProperties = this.applicationContext.getBean(WechatOpenProperties.class);
        }
        return this.wechatOpenProperties;
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }
}
